package com.wsseieiei.fireballgame.events;

import com.wsseieiei.fireballgame.Main;
import net.minecraft.network.chat.TranslatableComponent;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.client.event.RenderTooltipEvent;
import net.minecraftforge.event.entity.player.ItemTooltipEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;

import static com.wsseieiei.fireballgame.init.BlockEntityInit.CORE_BLOCK_ITEM;

@Mod.EventBusSubscriber(modid = Main.MOD_ID)
public class EventsToolTip {
    @OnlyIn(Dist.CLIENT)
    @SubscribeEvent
    public static void onToolTipColor(RenderTooltipEvent.Color event) {
//        if (event.getItemStack().getItem()==CORE_BLOCK_ITEM.get()) {
        try{
            if (event.getItemStack().getItem()==CORE_BLOCK_ITEM.get()) {
                event.setBackground(0xf0330000);
                event.setBorderStart(0xf0cc0000);
                event.setBorderEnd(0xf0cc0000);
            }
        } catch (Exception ignored) {}
    }


    @OnlyIn(Dist.CLIENT)
    @SubscribeEvent
    static void onToolTip(ItemTooltipEvent event)
    {
        ItemStack stack = event.getItemStack();
        Item item = stack.getItem();
        try{
            if (item==CORE_BLOCK_ITEM.get()){
                event.getToolTip().add(1, new TranslatableComponent("tip.fireballgame.core"));
            }
        } catch (Exception ignored) {}
    }
}
